package com.oocl.scan.store;

import com.oocl.scan.dao.SoapConfigDao;
import com.oocl.scan.dao.impl.SoapConfigDaoImpl;
import com.oocl.scan.model.SoapConfig;
import java.util.ArrayList;
import java.util.List;

public class SoapConfigStore {

  private List<SoapConfig> SoapConfigList;
  private static SoapConfigStore soapConfigStore;

  public SoapConfigStore() {
    this.SoapConfigList = new ArrayList<>();
  }

  public static SoapConfigStore getInstance() {
    if (soapConfigStore == null) {
      synchronized (SoapConfigStore.class) {
        if (soapConfigStore == null) {
          soapConfigStore = new SoapConfigStore();
        }
      }
    }
    return soapConfigStore;
  }

  public void add(SoapConfig soapConfig) {
    SoapConfigList.add(soapConfig);
  }

  public String get(String dtoName) {
    return soapConfigStore.get(dtoName);
  }

  private int getCount() {
    return this.SoapConfigList.size();
  }

  public List<SoapConfig> getSoapConfigList() {
    return SoapConfigList;
  }

  public void saveSoapConfig() {
    if (getCount() > 0) {
      SoapConfigDao dao = new SoapConfigDaoImpl();
      for (SoapConfig soapConfig : getSoapConfigList()) {
        dao.add(soapConfig);
      }
    }
  }

}
